package ru.volgogradetzzz.tween.easing  {

	public class Back {
		public static function easeIn(time:uint, before:Number, change:Number, duration:uint, overshoot:Number = 1.70158):Number {
			var ratio:Number = time/duration;
			return change * ratio * ratio * ((overshoot + 1) * ratio - overshoot) + before;
		}
		
		public static function easeOut(time:uint, before:Number, change:Number, duration:uint, overshoot:Number = 1.70158):Number {
			var ratio:Number = time / duration - 1;
			return change * (ratio * ratio * ((overshoot + 1) * ratio + overshoot) + 1) + before;
		}
		
		public static function easeInOut(time:uint, before:Number, change:Number, duration:uint, overshoot:Number = 1.70158):Number {
			var ratio:Number = time / duration * 2;
			if (ratio < 1) {
				return change / 2 * (ratio * ratio * (((overshoot *= (1.525)) + 1) * ratio - overshoot)) + before;
			}
			
			ratio -= 2;
			
			return change / 2 * (ratio * ratio * (((overshoot *= (1.525)) + 1) * ratio + overshoot) + 2) + before;
		}		
	}
}
